package com.server;

import com.server.executor.pool.OrderControlThreadPoolExecutor;
import com.server.server.NettyAppLauncher;
import com.server.rule.RuleEngineLauncher;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Description: This is a sample class.
 * @Author Simon
 */
@Slf4j
public class Starter {

    public static void main(String[] args) {
        log.info("程序启动");
        ThreadPoolExecutor orderThreadPool = OrderControlThreadPoolExecutor.getInstance();
        CompletableFuture<Void> initOrder= CompletableFuture.runAsync(()->initRuleEngine(),orderThreadPool);
        initOrder.thenRun(()->initNettyServer());
//        initRuleEngine();
//        initNettyServer();

    }

        // 主要考虑到之后可能有拓展  所以进行了多层封装
     static void initRuleEngine(){
         log.info("规则引擎初始化");
         RuleEngineLauncher.startRuleEngineService();
         log.info("规则引擎初始化成功");
     }

     static void initNettyServer(){
         NettyAppLauncher.startServer();
     }

}
